package com.likeyoudo.views.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.likeyoudo.common.BaseFragment;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author LikeYouDo
 * @date 2023/12/21 18:43
 */
public class FragmentAdapter extends FragmentStateAdapter {

    private final List<BaseFragment> fragmentList;

    public FragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle, List<BaseFragment> fragmentList) {
        super(fragmentManager, lifecycle);
        this.fragmentList = fragmentList;
    }

    @NotNull
    @Override
    public Fragment createFragment(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getItemCount() {
        return fragmentList.size();
    }
}
